# 导包
import requests
import unittest
# 创建测试类
class ihrm_login(unittest.TestCase):
    def setUp(self):
# 实例化session对象
        self.session = requests.Session()
# 定义正如接口url地址
        self.url_login = "http://ihrm-test.itheima.net/api/sys/login"
# teardown
    def tearDown(self):
# 关闭session对象
        self.session.close()
# 登录成功
    def test01_success(self):
# 发登录请求并断言
        login_data = {
    "mobile": "13800000002",
    "password": "123456"
}
        response = self.session.post(url=self.url_login, json=login_data)
        print(response.json())
        self.assertEqual(200, response.status_code)
        self.assertIn("操作成功",response.json().get("message"))
    def test02_fail(self):
        login_data={
    "mobile": "1380000000",
    "password": "123456"
}
        response = self.session.post(url=self.url_login, json=login_data)
        print(response.json())
        self.assertEqual(200, response.status_code)
        self.assertIn("用户名或密码错误", response.json().get("message"))

